package com.su.lesson01;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class EXDemo {
    public static void main(String[] args) {
        //总的弹窗
        Frame frame = new Frame();
        frame.setBounds(100,100,500,500);
        frame.setBackground(Color.green);
        frame.setVisible(true);
        frame.setLayout(new GridLayout(2,1));

        //4个面板
        Panel p1 = new Panel(new BorderLayout());
        Panel p2 = new Panel(new GridLayout(2,1));
        Panel p3 = new Panel(new BorderLayout());
        Panel p4 = new Panel(new GridLayout(2,2));
        //上面
        p1.add(new Button("East - 1"), BorderLayout.EAST);
        p1.add(new Button("West - 1"),BorderLayout.WEST);

        p2.add(new Button("p2 - btn - 1"));
        p2.add(new Button("p2 - btn - 2"));
        p1.add(p2,BorderLayout.CENTER);

        //下面
        p3.add(new Button("East - 2"), BorderLayout.EAST);
        p3.add(new Button("West - 2"),BorderLayout.WEST);
        //中间四个
        for(int i = 1;i <= 4;i++){
            p4.add(new Button("for - "+i));
        }
        p3.add(p4,BorderLayout.CENTER);
        frame.add(p1);
        frame.add(p3);
        //关闭弹窗
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

    }
}
